package dao.hibernate;

import java.sql.SQLException;
import java.util.List;

import model.SysModule;
import model.SysRole;

import org.springframework.stereotype.Repository;

import dao.SysRoleDao;

@Repository
public class SysRoleDaoHibernate extends GenericDaoHibernate<SysRole, Integer> implements SysRoleDao {

	public SysRoleDaoHibernate() {
		super(SysRole.class);
	}

	public List<SysModule> queryModules(Integer roleId) {
		return (List<SysModule>)getHibernateTemplate().find("select r.modules from SysRole r where r.id = ?", roleId);
	}
	
	public List query() {
		try {
			return getSqlMapClient().queryForList("app.nativeSQL", "select * from t_sys_role");
		} catch (SQLException e) {
			log.error("sql error:" + e);
			return null;
		}
	}
}
